package constants

import (
	"HandWritingJVM/instructions/base"
	"HandWritingJVM/rtda"
)

type BIPUSH struct {
	val int8
}

//从操作数中获取一个byte型正式，扩展成int，然后推入栈顶
func (self *BIPUSH) FetchOperands(reader *base.BytecodeReader) {
	self.val = reader.ReadInt8()
}

func (self *BIPUSH) Execute(frame *rtda.Frame) {
	i := int32(self.val)
	frame.OperandStack().PushInt(i)
}

type SIPUSH struct {
	val int16
}

//从操作数中获取一个short型正式，扩展成int，然后推入栈顶
func (self *SIPUSH) FetchOperands(reader *base.BytecodeReader) {
	self.val = reader.ReadInt16()
}

func (self *SIPUSH) Execute(frame *rtda.Frame) {
	frame.OperandStack().PushInt(int32(self.val))
}
